<template>
  <div class="jiesuanhu">
    <div class="main">
        <div class="main-left">
          <div class="left-top"><i class="el-icon-platform-eleme"></i>暂无图标</div>
          <div class="left-bottom" v-show="realnameBtn">
            <!-- <div> -->
              <p><span>电子账户名称：</span>{{form.electronicAccountName}}</p>
              <el-divider></el-divider>
              <p><span>电子账户账号：</span>{{form.electronicAccountCode}}</p>
            <!-- </div> -->
            <el-divider></el-divider>
            <!-- <div> -->
              <p><span>企业名称：</span>{{form.enterpriseName}}</p>
              <!-- <p><span>联行号：</span>{{form.electronicAccountBankCode}}</p> -->
            <!-- </div> -->
            <el-divider></el-divider>
            <!-- <div>
              <p><span>结算账号：</span>1599349260146973000233688</p>
              <p><span>结算账户编号：</span>10419090216171801</p>
            </div> -->
          </div>
          <div class="left-bottoms norealname" v-show="!realnameBtn">
            <div class="bottom">
              <p><span>未实名认证：</span><el-button type="primary" @click="maskrealnameShow">去实名</el-button></p>
            </div>
          </div>
        </div>
        <div class="main-right">
          <div class="money">{{form.des}}</div>
          <div class="yue">可用余额</div>
          <div class="btn">
            <el-button v-show="showBtn" @click="onlineBanking" type="primary">网银充值</el-button>
            <el-button v-show="!showBtn" @click="quickRecharge" type="primary">快捷充值</el-button>
            <el-button type="success">提现</el-button>
          </div>
          <maskrealname :showMask="showMask" @changeComponent1Data="component1DataChange"></maskrealname>
          <div class="maskRecharge" v-if="isShow" @click.self="maskShow">
            <div>
              <div>
                <span>充值账户账号：</span>
               <el-input v-model="form.electronicAccountCode" :disabled="true" placeholder="请输入内容"></el-input>
              </div>
              <div>
                <span>电子账户名称：</span>
               <el-input v-model="form.electronicAccountName" :disabled="true" placeholder="请输入内容"></el-input>
              </div>
              <div>
                <span>充值金额：</span>
               <el-input v-model="reCharge.amount" placeholder="请输入内容"></el-input>
              </div>
              <div>
                <span>充值方式：</span>
               <el-input :disabled="true" v-model="paymentWay"></el-input>
              </div>
              <div v-show="selectShow">
                <span>银行卡类型：</span>
               <template>
                <el-select @change="bankDepositcode" v-model="value" placeholder="请选择">
                  <el-option
                    v-for="item in bankDeposit"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </template>
              </div>
              <p>
              <el-button @click="cancelRecharge">取消</el-button>
              <el-button @click="sureRecharge" type="primary">确认</el-button>
                
              </p>
            </div>
          </div>
        </div>

    </div>
  </div>
</template>

<script>
import { isRealname,quickInternet } from "@/api/insurance/main";
import maskrealname from "@/components/maskRealname/Maskrealname";
export default {
  
  created() {
    this.getRealname();
  },
  data() {
    return {
      realnameBtn: true,
      showMask: false,
      showBtn: false,
      isShow: false,
      selectShow:false,
      form: {},
      value:"",
      reCharge:{
        accountId:"",
        paymentWay:"",
        amount:"",//充值金额
        bankId:"",//银行编号
      },
      paymentWay:"网银支付",
      // 开户银行
      bankDeposit: [
        { label: "100-邮储银行", value: "1" },
        { label: "102-工商银行", value: "2" },
        { label: "103-农业银行", value: "3" },
        { label: "104-中国银行", value: "4" },
        { label: "105-建设银行", value: "5" },
        { label: "301-交通银行", value: "6" },
        { label: "302-中信银行", value: "7" },
        { label: "303-光大银行", value: "8" },
        { label: "304-华夏银行", value: "9" },
        { label: "305-民生银行", value: "10" },
        { label: "306-广发银行", value: "11" },
        { label: "307-平安银行", value: "12" },
        { label: "308-招商银行", value: "13" },
        { label: "309-兴业银行", value: "14" },
        { label: "310-浦发银行", value: "15" },
        { label: "311-恒丰银行", value: "16" },
        { label: "441-重庆银行", value: "17" },
        { label: "1413-重庆农村商业银行", value: "18" },
        { label: "321-重庆三峡银行", value: "19" },
        { label: "1731-重庆富民银行", value: "20" },
        { label: "429-成都银行", value: "21" },
        { label: "1528-成都农村商业银行", value: "22" },
        { label: "1747-四川新网银行股份有限公司", value: "23" },
        { label: "1804-四川天府银行股份有限公司", value: "24" },
        { label: "-201-国家开发银行", value: "25" },
        { label: "440-徽商银行", value: "26" },
        { label: "1436-贵州省农村信用社联合社", value: "27" },
        { label: "1569-贵州银行", value: "28" },
        { label: "443-贵阳银行（贵阳市商业银行）", value: "29" },
        { label: "489-广东南粤银行", value: "30" },
        { label: "701-昆仑银行", value: "31" },
        { label: "316-浙商银行", value: "32" },
        { label: "317-渤海银行", value: "33" },
        { label: "1715-上海华瑞银行", value: "34" },
        { label: "1716-浙江网商银行", value: "35" },
        { label: "442-哈尔滨银行", value: "36" }
      ],
    };
  },
  components: {
    maskrealname
  },
  methods: {
    component1DataChange(params) {
      this.showMask = params;
    },
    maskrealnameShow() {
      this.showMask = true;
    },
    getRealname() {
      let accountId = sessionStorage.getItem("username");
      let deptId = sessionStorage.getItem("deptId");
      isRealname({ phone: accountId, deptId: deptId }).then(data => {
        console.log(data.data);
        if (
          data.data.code=="2011"
        ) {
          this.realnameBtn = false;
        } else {
          let params = {
            electronicAccountCode: data.data.data.electronicAccountCode,
            electronicAccountName: data.data.data.electronicAccountName,
            enterpriseName: data.data.data.enterpriseName,
            remark: data.data.data.remark,
            des: data.data.data.des
          };
          let des = params.des / 100;
          var c =
            des.toString().indexOf(".") !== -1
              ? des.toLocaleString()
              : des.toString().replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
          if (!isNaN(c)) {
            let num = 0.0;
            params.des = num.toFixed(2);
          } else {
            params.des = c;
          }
          if (data.data.data.remark == "1") {
            this.showBtn = true;
          } else {
            this.showBtn = false;
          }
          this.form = params;
          this.realnameBtn = true;
        }
      });
    },
    sureRecharge(){
      this.reCharge.accountId = sessionStorage.getItem("username")
      console.log(this.reCharge);
      quickInternet(this.reCharge)
      .then(data => {
        console.log(data.data,"快捷充值数据");
        
      })
      .catch(()=>{

      })
    },
    // 网银充值
    onlineBanking(){
      this.reCharge.paymentWay = "20"
      this.isShow = true
      this.selectShow = true    
      this.paymentWay = "网银充值"
    },
    // 快捷充值
    quickRecharge(){
      this.reCharge.paymentWay = "10"
      this.isShow = true
      this.selectShow = false
      this.paymentWay = "快捷充值"
    },
    // 取消按钮
    cancelRecharge(){
      this.isShow = false
    },
    //蒙版层消失
    maskShow() {
      this.isShow = false;
    },
    // 获取银行编码
    bankDepositcode(value) {
      let bankDepositcodedata = this.bankDeposit.filter(function(item) {
        return item.value == value;
      });
      for (let i = 0; i < bankDepositcodedata.length; i++) {
        var bankDepositcodeindex = bankDepositcodedata[i].label.indexOf("-");
        this.reCharge.bankId = bankDepositcodedata[i].label.substring(
          0,
          bankDepositcodeindex
        );
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.jiesuanhu {
  padding: 10px;
  .main {
    background: #fff;
    display: flex;
    border-radius: 10px;
    padding: 20px 30px;
    .main-left {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1.5;
      .left-top {
        border-right: 1px solid #ccc;
        font-size: 26px;
        display: flex;
        align-items: center;
        i {
          color: blue;
          margin-right: 10px;
        }
      }
      .left-bottom {
        display: flex;
        flex-direction: column;
        padding-left: 80px;
        border-right: 1px solid #ccc;
        // & > div {
          // display: flex;
          p {
            span {
              color: #aaacac;
            }
            margin-right: 30px;
          }
        // }
        .el-divider--horizontal {
          margin: 0;
          width: 500px;
        }
      }
      .bottom {
        p {
          margin: 0;
        }
      }
    }
    .main-right {
      flex: 1;
      display: flex;
      flex-direction: column;
      .money {
        display: flex;
        justify-content: flex-end;
        font-size: 34px;
        margin-bottom: 10px;
      }
      .yue {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20px;
      }
      .btn {
        display: flex;
        justify-content: flex-end;
        button {
          border-radius: 4px;
        }
      }
    }
  }
}
.maskRecharge {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  & > div {
    width: 66%;
    background: #fff;
    padding: 20px;
    overflow: hidden;
    max-height: 80%;
    overflow-y: scroll;
    line-height: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    & > div {
      width: 30%;
      display: flex;
      margin-bottom: 30px;
      span {
        display: inline-block;
        width: 100px;
      }
      .el-input {
        flex:1;
      }
    }
    p{
      width: 30%;
      display: flex;
      justify-content: space-around;
    }
  }
  & > div::-webkit-scrollbar {
    width: 0;
    height: 0;
    background-color: transparent;
  }
}
</style>